﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Routing;

namespace BastInfos
{
	public class MvcApplication : System.Web.HttpApplication
	{
		public static void RegisterRoutes(RouteCollection routes)
		{
			routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

			AreaRegistration.RegisterAllAreas();

			//Home
			routes.MapRoute(
				"Home"
				, "accueil.html"
				, new { controller = "Home", action = "Index" }
				, new string[] { "BastInfos.Controllers" }
			);
			routes.MapRoute(
				"About"
				, "nous.html"
				, new { controller = "Home", action = "About" }
				, new string[] { "BastInfos.Controllers" }
			);
			routes.MapRoute(
				"Contact"
				, "contact.html"
				, new { controller = "Home", action = "Contact" }
				, new string[] { "BastInfos.Controllers" }
			);

			//Article
			routes.MapRoute(
				"ArticleList"
				, "articles.html"
				, new { controller = "Article", action = "List" }
				, new string[] { "BastInfos.Controllers" }
			);
			routes.MapRoute(
				"ArticleCategory"
				, "articles/{description}-{id}.html"
				, new { controller = "Article", action = "Category" }
				, new string[] { "BastInfos.Controllers" }
			);
			routes.MapRoute(
				"Article"
				, "article/{title}-{id}.html"
				, new { controller = "Article", action = "Detail" }
				, new string[] { "BastInfos.Controllers" }
			);

			//Event
			routes.MapRoute(
				"EventList"
				, "evenements.html"
				, new { controller = "Event", action = "List" }
				, new string[] { "BastInfos.Controllers" }
			);
			routes.MapRoute(
				"EventCategory"
				, "evenements/{description}-{id}.html"
				, new { controller = "Event", action = "Category" }
				, new string[] { "BastInfos.Controllers" }
			);
			routes.MapRoute(
				"Event"
				, "evenement/{title}-{id}.html"
				, new { controller = "Event", action = "Detail" }
				, new string[] { "BastInfos.Controllers" }
			);

			//Publication
			routes.MapRoute(
				"PublicationList"
				, "publications.html"
				, new { controller = "Publication", action = "List" }
				, new string[] { "BastInfos.Controllers" }
			);
			routes.MapRoute(
				"PublicationYear"
				, "publications/{year}.html"
				, new { controller = "Publication", action = "Year" }
				, new { year = new BastInfos.Helpers.RouteHelper.YearRouteConstraint() }
				, new string[] { "BastInfos.Controllers" }
			);

			//Publication
			routes.MapRoute(
				"Visitor"
				, "espace-lecteurs.html"
				, new { controller = "Visit", action = "Index" }
				, new string[] { "BastInfos.Controllers" }
			);

			routes.MapRoute(
				"Default"
				, "{controller}/{action}"
				, new { controller = "Home", action = "Index" }
				, new string[] { "BastInfos.Controllers" }
			);
		}

		protected void Application_Start()
		{
			RegisterRoutes(RouteTable.Routes);
		}
	}
}